import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-05-04
 * Time: 15:06
 */
public class TestCard {
    public static final String[] suits={"♦","♣","♥","♠"};

    public static List<Card> buyCard(){
        List<Card> desk=new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                String suit=suits[i];
                Card card=new Card(suit,j);
                desk.add(card);
            }
        }
        return desk;
    }

    public static void swap(List<Card> cardList,int i,int index){
        Card tmp=cardList.get(index);
        cardList.set(index,cardList.get(i));
        cardList.set(i,tmp);
    }

    public static void shuffle(List<Card> cardList){
        for (int i = cardList.size()-1; i > 0 ; i--) {
            Random random=new Random();
            int index=random.nextInt(i);
            swap(cardList,i,index);
        }
    }
}
